//
//  HLLiveInputView.m
//  YueYue
//
//  Created by hulu001 on 2024/3/12.
//

#import "HLLiveInputView.h"

@implementation HLLiveInputView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColorWhite;
        [self mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 48));
        }];
        self.textfield = [[UITextField alloc] init];
        _textfield.placeholder = @"｜说点什么…";
        _textfield.font = [UIFont systemFontOfSize:12];
        [self addSubview:_textfield];
        [_textfield mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.top.mas_equalTo(8);
            make.bottom.mas_equalTo(-8);
            make.right.mas_equalTo(-78);
        }];
        
        
        self.sendButton = [[QMUIButton alloc] init];
        self.sendButton.backgroundColor = HLMainColor;
        self.sendButton.layer.cornerRadius = 16;
        self.sendButton.layer.masksToBounds = YES;
        self.sendButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
        [self.sendButton setTitle:@"发送" forState:UIControlStateNormal];
        [self.sendButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        [self.sendButton addTarget:self action:@selector(sendEvent:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.sendButton];
        [_sendButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(48, 32));
            make.centerY.mas_equalTo(0);
            make.right.mas_equalTo(-10);
        }];
    }
    return self;
}

- (void)sendEvent:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(liveInputView:willSend:)]) {
        [self.delegate liveInputView:self willSend:self.textfield.text];
    }
    self.textfield.text = @"";
}
@end
